package com.neu.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neu.po.Dept;
import com.neu.po.Emp;
import com.neu.po.Post;
import com.neu.po.ResponseResult;
import com.neu.service.EmpService;
@RestController
@RequestMapping("emp")
public class EmpController {
	@Autowired
	private EmpService empService;
	
	@RequestMapping("getByDept")
	public ResponseResult getByDept (@RequestBody Dept dept) {
		ResponseResult result = new  ResponseResult();
		result.setData(empService.getByDept(dept));
		   
		return result;
	
	}
	
	@RequestMapping("getAll")
	public ResponseResult getAll(Emp emp) {
		
		ResponseResult result = new ResponseResult();
		result.setData(empService.getAll());
		
		
		return result;
		
	}
   	
	@RequestMapping("getPaged")
	public ResponseResult getPaged(int pageNum, int pageSize) {
		ResponseResult result = new  ResponseResult();
		result.setData(empService.getPaged(pageNum, pageSize));
		
		return result;
	}
	
	@RequestMapping("insert")
	public ResponseResult insert(@RequestBody Emp emp) {
		ResponseResult result = new  ResponseResult();
		result.setData(empService.insert(emp));
		
		return result;
	}
	
	@RequestMapping("getByPost")
	public ResponseResult getByPost(@RequestBody Post post) {
		ResponseResult result = new  ResponseResult();
		result.setData(empService.getByPost(post));
		
		return result;
	}
	
	@RequestMapping("getById")
	public ResponseResult getById(int id) {
		ResponseResult result = new  ResponseResult();
		result.setData(empService.getById(id));
		
		return result;
	}
	@RequestMapping("update")
	public ResponseResult update(@RequestBody Emp emp) {
		ResponseResult result = new  ResponseResult();
		result.setData(empService.update(emp));
		
		return result;
	}
	
}
